<?php

	include_once('../sys/sys.php');
	header('Content-Type: text/html; charset=utf-8');
	$chalis = array();
	$j = 0;
	for ($i = "A"; $i != "Z"; $i++) {
		$chalis[$j]['chaName'] = $i;
//		$chalis[$i]['chaName'] = SITE_URL . "xdm/class.php?classid=" . $i;
		$chalis[$j]['chaLink'] = SITE_URL . "xdm/class.php?classid=" . $i;
		//if ($i == "Z") {
		//	break;
		//}
		$j++;
	}
	$chalis[$j]['chaName'] = "Z";
	$chalis[$j]['chaLink'] = SITE_URL . "xdm/class.php?classid=Z";
	$j++;
	$chalis[$j]['chaName'] = "数";
	$chalis[$j]['chaLink'] = SITE_URL . "xdm/class.php?classid=num";
	
	//print_r($chalis);exit;
	
	
	
	//获取系统内容以及分页
	
	//获取分类以及分页号
	$st = $_GET['st'];
	$cid = $_GET['cid'];
	$jid = $_GET['jid'];
	if(is_null($st)){$st = 0;}
	//列出的图片数量(注意,不要超过15张)
	$listnum = 35;
	
	$array_piclist = array();
	
	
	$DB->build_query(array(
			'select' 	=> 'id,name,lastupdate,count',
			'from'		=> 'nonadmtags',
			'order'		=> 'lastupdate DESC',
			'limit'		=> array($st,$listnum)
	));
	$qid = $DB->exec_query();
	$i = 0;
	while ($row = $DB->fetch_row($qid)) {
		if($row['lastupdate'] <= 0) $row['lastupdate'] = 0;
		$array_piclist[$i]['tagname'] = $row['name'];
		$array_piclist[$i]['id'] = $row['id'];
		$array_piclist[$i]['count'] = $row['count'];
		$array_piclist[$i]['lastupdate'] = get_date($row['lastupdate']);
		$array_piclist[$i]['downloadpicslink'] = SITE_URL . 'nonadm/pics.php?action=getpicfiles&tid=' .$row['id'];
		$array_piclist[$i]['picslink'] = SITE_URL . 'nonadm/pics.php?action=getpicurls&tid=' .$row['id'];
		$array_piclist[$i]['getnewlink'] = SITE_URL . 'nonadm/cr.php?tid=' .$row['id'];
		$array_piclist[$i]['picsrc'] = SITE_URL . 'xdm/img/001.gif';
		$i++;
	}
	//处理分页信息
	//获取总TAG数
	$totalnumbers = get_count_of_field('nonadmtags','');
	$pagelink = $Elsesky->PageLinkR($st,$totalnumbers,$listnum,SITE_URL."nonadm/index.php?&st=<:st:>");
	
	//处理最常访问内容
	$ccount = 9;
	$array_ccount = array();
	
	$DB->build_query(array(
			'select' 	=> '*',
			'from'		=> 'nonadmtags',
			'order'		=> 'scount DESC',
			'limit'		=> array(0,$ccount)
	));
	$qid = $DB->exec_query();
	$i = 0;
	while ($row = $DB->fetch_row($qid)) {
		$array_ccount[$i]['tidname'] = $row['name'];
		$array_ccount[$i]['ccount'] = $row['scount'];
		$array_ccount[$i]['tidlink'] = SITE_URL . 'nonadm/search.php?name=' . $row['name'];
		$i++;
	}
	
	$news = $array_ccount;
	$lnews = $array_ccount;
	$onews = $array_ccount;
	$gts = $array_ccount;
	
	
	$nnotifs = array_slice($array_piclist,0,7);
	$piccomic = array_slice($array_piclist,0,5);
	
	$line1 = array_slice($array_piclist,0,5);
	$line2 = array_slice($array_piclist,0,5);
	$line3 = array_slice($array_piclist,0,5);
	$line4 = array_slice($array_piclist,0,5);
	$line5 = array_slice($array_piclist,0,5);
	$line6 = array_slice($array_piclist,0,5);
	
	
	//初始化模版变量
	$page = init_smart_template_obj('xdm/class.html',CACHE_DIR,CACHE_DIR,TEMPLATE_DIR);
	$page->assign("piclist",$array_piclist);
	$page->assign("system",$sysinfo);
	$page->assign("siteurl",$sysinfo[siteurl] ."xdm/");
	$page->assign("keywordscontent","测试内容");
	$page->assign("title","测试标题");
	$page->assign("keydescontent","测试关键字形容词");
	$page->assign("chalist",$chalis);
	//HOT的
	$page->assign("news",$news);
	$page->assign("lnews",$lnews);
	$page->assign("onews",$onews);
	$page->assign("gts",$gts);
	$page->assign("nnotifs",$nnotifs);
	$page->assign("piccomic",$piccomic);
	$page->assign("textnew",$array_piclist);
	
	
	$page->assign("line1",$line1);
	$page->assign("line2",$line2);
	$page->assign("line3",$line3);
	$page->assign("line4",$line4);
	$page->assign("line5",$line5);
	$page->assign("line6",$line6);
	
	
	
	
	
	
	
	
	$page->assign("pagelink",$pagelink);
	$page->assign("searchpg",SITE_URL . 'nonadm/search.php');
	
	$page->assign("tidlink",$array_ccount);
	$page->assign("ccount",$ccount);

	$page->output();
	
?>